<!DOCTYPE html>
<html>
<head>
    <title>robot's fight</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />

</head>


<body>

<p>

  <script src="./physicsjs-full.js"></script>

  <script src="./jquery.min.js"></script>
  <script src="./custom.js"></script>
  <script src="./behavior.js"></script>
    <script src="map/map1.js"></script>
  <canvas id="viewport" width="300" height="500" style="float: left"></canvas>
  <textarea id='custom' style="float: left"  cols="60" rows="30" >
</textarea>
</p>
<p>
  <input onclick="submit()" type="button" value="ok">
  <br/>
</p>
<div id="message">here</div>

<code id="class"></code>
<br/>
<p></p>
<div>

<code>
    function myrun(){
    mes.begin();
    var p1=mes.getPosition('enemy');
    var p2=mes.getPosition('player');
    var dx=p1.x-p2.x;var dy=p1.y-p2.y;
    var angle=Math.atan2(dy,dx);
    var a1=mes.getAngular('player');
    //mesbox.innerHTML='a:'+(angle-a1);
    this.turn(angle-a1);
    this.attack();
    mes.end();
    }
</code>

</div>
<script src="./main.js"></script>
<input type="submit" value="Submit" onClick="javascript:contact.startNewActivity()"/>
<script type="text/javascript">
    var mesbox=document.getElementById('message');
   function submit(){
       //world.start();
        var text=document.getElementById('custom').value;
       eval(text);
       console.log(Physics.util);
       map.player.run=myrun;
      // myrobot.run=text.constructor;

      // p1.bind(myrobot);
    }
    function show(a,b,c){
        var k=0.00001;
       // mesbox.innerHTML=w;
        mesbox.innerHTML=a+"<br/>"+b+"<br/>"+c+"<br/>";
        acc.setAcceleration({x:k*-a,y:k*b});
    }
function newactive (){
	contact.startNewActivity();
	}
</script>
</body>
</html>